# 微信一直挂在某台电脑上（先本地测试，后续云主机）
# 脚本识别服务号->点击预设服务号进去->点击分享按钮->点击"微信好友”->分享到群、
# 1、脚本识别（识别到服务号“xxx”通知），
# 2、识别到之后自动点进去，右上角转发按钮->脚本点击转发按钮
# 3、识别到转发按钮的左边”，分享好友，->脚本点击“分享好友”
# 4、根据代码里面识别的群聊，脚本循环转发到相应的微信群
import pytesseract
from PIL import Image
def ocr_image(image_path):
    """
    Perform OCR on the given image and return the recognized text.

    :param image_path: Path to the image file.
    :return: Recognized text from the image.
    """
    try:
        # Open the image using PIL
        img = Image.open(image_path)

        # Use pytesseract to do OCR on the image
        text = pytesseract.image_to_string(img, lang='chi_sim')

        return text.strip()
    except Exception as e:
        print(f"Error processing image {image_path}: {e}")
        return ""
if __name__ == "__main__":
    image_path = "path_to_your_image.png"  # Replace with your image path
    recognized_text = ocr_image(image_path)
    print(f"Recognized text: {recognized_text}")
    # You can add more code here to process the recognized text further
# or to integrate it with other functionalities.
